package com.hy.dao;

import com.hy.bean.*;
import com.hy.vo.BuytableVo;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;

/**
 * (Buytable)表数据库访问层
 *
 * @author makejava
 * @since 2024-05-14 22:03:32
 */
public interface BuytableDao {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    Buytable queryById(Integer id);

    /**
     * 查询指定行数据
     *
     * @return 对象列表
     */
    List<Map<String,Object>> queryAllByLimit(String state,Integer page, Integer limit) throws Exception;

    /**
     * 统计总行数
     *
     * @return 总行数
     */
    long count(String state) throws Exception;

    long countDetails(String state,String status,Integer id) throws Exception;

    long countStatis(String buyNumber, String buyer, String producername, String buyTime, String reachTime) throws Exception;

    /**
     * 新增数据
     *
     * @param connection
     * @param buytable   实例对象
     * @return 影响行数
     */
    int insert(Connection connection,Buytable buytable);


    /**
     * 修改数据
     *
     * @param connection
     * @param buytable   实例对象
     * @return 影响行数
     */
    int update(Connection connection,Buytable buytable);

    int updateBuyerAndBuyTimeById(Connection connection,Integer id, String name, Date buyTime,Double zje);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 影响行数
     */
    int deleteById(Integer id);

    List<Map<String, Object>> queryAllDetails(String state, String status, Integer id, Integer page, Integer limit) throws Exception;

    /*
     * 根据状态(state)查询采购信息
     * */
    List<Map<String,Object>> queryAllStatis(String buyNumber,String buyer, String producername, String buyTime,String reachTime, Integer page, Integer limit) throws Exception;

    List<Buytable> selectAll();

    BuytableVo selectById(Integer id);

    Buytable selectByRequestTime(String requestTime);

    boolean updateState(Integer id,String state, Connection conn) throws Exception;

    boolean updateInfo(Integer id,String Info,Connection conn) throws Exception;

    boolean updateUser(Integer id,Integer person,String time,Integer person1,String time1,Connection conn) throws Exception;

    List<Producertable> queryAllVendor() throws Exception;

    long countCar(String name) throws Exception;

    int insertCar(Carpartstable car,Connection conn) throws SQLException;

    int insertBuyPart(BuyParttable buyParttable,Connection conn) throws SQLException;

    int updateBuy(Connection conn,Double totalPrice,Integer id,Integer buyCount) throws SQLException;

    int updateCar(Connection conn,Double costPrice,Integer id,String partDetailChanger) throws SQLException;

    int updateCode(String code, Integer id, String name) throws Exception;

    boolean deleteCarPart(Integer id, Connection conn) throws SQLException;

    boolean deleteBuyPart(Integer id, Connection conn) throws SQLException;

    List<Producertable> listProducertable(Integer page, Integer limit) throws Exception;

    long countProducertable() throws Exception;

     int addProducertable(Producertable producertable) throws Exception;

     int updateProducertable(Producertable producertable) throws Exception;

     int deleteProducertable(Integer id) throws Exception;

    int updateUserTime(Integer id,int userId,String time,Connection conn) throws SQLException;

    int updateBuyTotalPrice(Connection conn,Integer id) throws SQLException;

}

